//----------------------------------------------------------------------------
// File       : tTask_Core.h
// Function   : Provide the main function of task scheduler.
// Description: To be done.
// Version    : V1.00
// Author     : Ian
// Date       : 29th Apr 2016
// History    :  No.  When           Who           What
//               1    29/Apr/2016    Ian           Create
//----------------------------------------------------------------------------

#ifndef __TASK_CORE_H_
#define __TASK_CORE_H_




#include <Source/System/inc/Task_Type.h>



//
#define TASK_NO_TASK                (0x00)                    // Task number which means there is no task
#define TASK_ALL_TASK               (0xFF)                    // Task number which means all tasks
#define TASK_FIRST_TASK             (0x01)                    // Task number of the first one
#define TASK_LAST_TASK               MAX_TASK_NUM              // Task number of the last one


#define MAX_HANDLE_QUEUE            256

#define DISPATCH            0


#if DISPATCH
//typedef void (*cb_t)(uint16_t event);
#else

typedef void (*cb_t)(void);

#endif


typedef enum _TaskSt_t
{
      TASK_OK = 0,
      TASK_RUN,
      TASK_HALT,
      TASK_WAILT,
      TASK_EXIST,
      TASK_NOT,
      TASK_EMPTY,
      TASK_FULL
}TaskSt_t;

typedef struct _Task_t
{
    uint8_t event;
    uint8_t status;
    uint32_t timeout;
    uint32_t repeat;
    cb_t cb;
}Task_t;







#ifdef __cplusplus
extern "C" {
#endif




uint8_t  Task_Init(void);
void     Task_Run(void);

TaskSt_t Task_Add(cb_t pFunc);

TaskSt_t Task_Del(cb_t pFunc);

TaskSt_t TimerTask_Add(cb_t pFunc, uint32_t timeout, uint32_t repeat);

void TaskTickHandler(void);
void TaskTick(void);

#ifdef __cplusplus
}
#endif

#endif // _TTASK_CORE_H_

// End of file

